package com.yshy.moviechoseseatinginnerapi.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yshy.moviechoseseatinginnerapi.service.ShowsService;
import com.yshy.moviechoseseatingcommon.entity.bo.shows.*;
import com.yshy.moviechoseseatingcommon.entity.vo.shows.*;
import com.yshy.moviechoseseatingcommon.util.RequstUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author :
 * @desc :
 * @create: 下午2:14
 **/
@Service
public class ShowsServiceImpl implements ShowsService {
    @Autowired
    private RequstUtil requstUtil;

    @Override
    public String listByCinemaId(ListByCinemaIdBo bo) {
        ListByCinemaIdVo listByCinemaIdVo = requstUtil.showsListByCinemaId(bo);
        if(listByCinemaIdVo==null){
            return "请求异常";
        }
        return JSONObject.toJSONString(listByCinemaIdVo, SerializerFeature.WriteMapNullValue);
    }

    @Override
    public String listByCityAndFilm(ListByCityAndFilmBo bo) {
        if(bo.getCityId()==null&&bo.getCityCode()==null){
            return "参数异常,城市Id，和城市编号二选一";
        }
        if(bo.getCityId()!=null&&bo.getCityCode()!=null){
            return "参数异常,城市Id，和城市编号二选一";
        }
        ListByCityAndFilmVo listByCityAndFilmVo = requstUtil.showsListByCityAndFilm(bo);
        if(listByCityAndFilmVo==null){
            return "请求异常";
        }
        return JSONObject.toJSONString(listByCityAndFilmVo,SerializerFeature.WriteMapNullValue);
    }

    @Override
    public String listByCityId(ListsByCityIdBo bo) {
        if(bo.getCityId()==null&&bo.getCityCode()==null){
            return "参数异常,城市Id，和城市编号二选一";
        }
        if(bo.getCityId()!=null&&bo.getCityCode()!=null){
            return "参数异常,城市Id，和城市编号二选一";
        }
        ListsByCityIdVo listsByCityIdVo = requstUtil.showsListByCityId(bo);
        if(listsByCityIdVo==null){
            return "请求异常";
        }
        return JSONObject.toJSONString(listsByCityIdVo,SerializerFeature.WriteMapNullValue);
    }

    @Override
    public String listByCinemaAndFilm(ListByCinemaAndFilmBo bo) {
        ListByCinemaAndFilmVo listByCinemaAndFilmVo = requstUtil.showsListByCinemaAndFilm(bo);
        if(listByCinemaAndFilmVo==null){
            return "请求异常";
        }
        return JSONObject.toJSONString(listByCinemaAndFilmVo,SerializerFeature.WriteMapNullValue);
    }

    @Override
    public String getRealTimeSeatByShowId(GetRealTimeSeatByShowIdBo bo) {
        GetRealTimeSeatByShowIdVo getRealTimeSeatByShowIdVo = requstUtil.showsGetRealTimeSeatByShowId(bo);
        if(getRealTimeSeatByShowIdVo==null){
            return "请求异常";
        }
        return JSONObject.toJSONString(getRealTimeSeatByShowIdVo,SerializerFeature.WriteMapNullValue);
    }

    @Override
    public String pagedQuery(PagedQueryBo bo) {
        PagedQueryVo pagedQueryVo = requstUtil.showsPagedQuery(bo);
        if(pagedQueryVo==null){
            return "请求异常";
        }
        return JSONObject.toJSONString(pagedQueryVo,SerializerFeature.WriteMapNullValue);
    }

    @Override
    public String v1ListShowDate(V1ListShowDateBo bo) {
        V1ListShowDateVo v1ListShowDateVo = requstUtil.showsV1ListShowDate(bo);
        if(v1ListShowDateVo==null){
            return "请求异常";
        }
        return JSONObject.toJSONString(v1ListShowDateVo,SerializerFeature.WriteMapNullValue);
    }

    @Override
    public String v2ListShowDate(V2ListShowDateBo bo) {
        V2ListShowDateVo v2ListShowDateVo = requstUtil.showsV2ListShowDate(bo);
        if(v2ListShowDateVo==null){
            return "请求异常";
        }
        return JSONObject.toJSONString(v2ListShowDateVo,SerializerFeature.WriteMapNullValue);
    }
}
